package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleService;
import com.heima.common.constant.ArticleConstants;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 首页头条管理接口
 */
@RestController
@Slf4j
//@Api(tags = "首页头条管理接口")
@RequestMapping("/api/v1/article")
public class ArticleHomeController {

    @Autowired
    private ApArticleService articleService;

    /**
     * 加载首页
     * @param dto
     * @return
     */
//    @ApiOperation("加载首页")
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto){
        log.info("【{}】方法:加载首页，接收信息【{}】",this.getClass().getName(),dto);
        //return articleService.load(dto,ArticleConstants.LOADTYPE_LOAD_MORE);
        return articleService.load2(dto,ArticleConstants.LOADTYPE_LOAD_MORE,true);
    }
    /**
     * 加载更多
     * @param dto
     * @return
     */
//    @ApiOperation("加载更多")
    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        log.info("【{}】方法:加载更多，接收信息【{}】",this.getClass().getName(),dto);
        return articleService.load(dto,ArticleConstants.LOADTYPE_LOAD_MORE);
    }
    /**
     * 加载最新
     * @param dto
     * @return
     */
//    @ApiOperation("加载最新")
    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        log.info("【{}】方法:加载更新，接收信息【{}】",this.getClass().getName(),dto);
        return articleService.load(dto,ArticleConstants.LOADTYPE_LOAD_NEW);
    }

}
